package com.ruoyi.consumer.controller;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.consumer.domain.CRequirement;
import com.ruoyi.consumer.service.impl.CRequirementServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: lizhouwei
 * @ date : 2023/10/19
 * @description:
 */
@Api(tags = "消费者需求")
@RestController
@RequestMapping("/api/consumer/requirement")
public class ConsumerRequirementController {

    @Autowired
    private CRequirementServiceImpl requirementService;

    /**
     * 我发布的需求列表
     * @param consumerId
     * @return
     */
    @ApiOperation("需求列表")
    @GetMapping("/getList")
    public AjaxResult requirementList(@ApiParam(value = "消费者id", required = true) Integer consumerId,
                                      @ApiParam(value = "订单状态", required = true) Integer status,
                                      @ApiParam(value = "页码", required = true) Integer pageNum,
                                      @ApiParam(value = "页数", required = true) Integer pageSize) {
        Assert.notNull(consumerId, "消费者id不能为空");
        PageHelper.startPage(pageNum, pageSize);
        PageHelper.orderBy("create_time desc");
        CRequirement cRequirement = new CRequirement();
        cRequirement.setConsumerId(consumerId);
        cRequirement.setStatus(status);
        return AjaxResult.success(requirementService.selectCRequirementList(cRequirement));
    }
}
